import torch

loss = torch.nn.SmoothL1Loss()
input = torch.tensor([[ 0.4833, -0.9410, -0.2800],
                      [-0.9127, -0.6625, -0.1461],
                      [ 0.2691, -1.2371, -1.7231]], requires_grad=True)
print(input)
target = torch.tensor([[-1.9744,  0.0290, -0.0641],
                       [-0.2312, -0.3604,  0.6289],
                       [-0.9326, -1.7833, -0.2735]])
print(target)
out_loss = loss(input, target)
print(out_loss)
out_loss.backward()

'''tensor([[ 0.4833, -0.9410, -0.2800],
        [-0.9127, -0.6625, -0.1461],
        [ 0.2691, -1.2371, -1.7231]])
tensor([[-1.9744,  0.0290, -0.0641],
        [-0.2312, -0.3604,  0.6289],
        [-0.9326, -1.7833, -0.2735]])
tensor(0.5367)
'''

'''
0.5(y-f(x))^2   dealt < 1
|y-f(x)| - 0.5

'''